README: Replication Package for "Do External Threats Reduce Affective Polarization? An Experiment on Russia's Invasion of Ukraine"

1. Overview
This replication package contains all necessary files to reproduce the results presented in the manuscript **"Do External Threats Reduce Affective Polarization? An Experiment on Russia’s Invasion of Ukraine"** by Jonas Pilgaard Kaiser & Markus Seier.

The package includes the dataset, analysis scripts, and a codebook detailing the variables used in the study. The analyses were conducted in **Stata** version 18.

2. Files Included
- **Dataset:**
  - `Data_Clean.dta`: The anonymized and cleaned dataset used for all analyses in the paper and appendix.
- **Stata Do-Files:**
  - `Main_Paper.do`: This script replicates all results from the main paper, including tables and figures.
  - `Appendix.do`: This script replicates all results from the online appendix.
  - `PowerSimulation.do`: This script replicates the results of the power simulations.
- **Supporting Documents:**
  - `Codebook.pdf`: A codebook describing the variables in the dataset.
  - `README.txt` (this file): Instructions for using the replication package.
  - `Replication_Appendix_Log.txt`: A log from running `Appendix.do` that replicates all results from the online appendix.
  - `Replication_Main_Log.txt`: A log from running `Main_Paper.do` that replicates all results from the online appendix.

3. Software Requirements
- **Stata (version 16 or newer)**
- The following external Stata packages must be installed before running the replication scripts:
  ```stata
  ssc install estout   // Required for 'estpost' and 'esttab' commands (table exports)
  ssc install tabout   // Required if using 'tabout' for alternative table exports
  ssc install vioplot  // Required for generating violin plots
  ssc install rwolf2.  // Required for multiple hypothesis testing results
  ```
- The scripts should work on Windows, Mac, and Linux systems without modification.

4. Instructions for Replication
1. **Open Stata** and set the working directory to the location where the replication package is stored:
   ```stata
   cd "[your_path_here]"
   ```
2. **Run the main analysis (approx. 2 minutes):
   ```stata
   do Main_Paper.do
   ```
3. **Run the appendix analysis (approx. 3 minute):
   ```stata
   do Appendix.do
   ```
4. **Run power analysis (approx. 5 minutes):
   ```stata
   do PowerSimulation.do
   ```

Both scripts generate all tables and figures presented in the manuscript and online appendix (the layout of the tables has been manually adjusted in latex). The figures are automatically saved in the **`figures/`** folder.

5. Expected Output
- Tables and figures will be displayed in the **Stata results window** and saved as `.eps` files in the **`figures/`** directory.
- The log files (`main_analysis.log` and `appendix_analysis.log`) will document the execution of the scripts.